package com.demo.hotel_book.mapper;

import com.demo.hotel_book.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserMapper {

    @Select("select * from user where username=#{username} or email=#{email}")
    User seluerByname(User user);

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into user(username,email,password) values(#{username},#{email},#{password})")
    int insertUser(User user);

    @Select("select * from user where username=#{username} and password=#{password}")
    User loginUser(User user);

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Update("update user set password=#{password} where email=#{email}")
    int reset(User user);
}
